<div id="variant"></div>

<%= spinner %>

<% columns = @product.variants_with_master.collect {|v| v.parameter_values.count}.max %>

<table class="table">
  <thead>
    <th class="first"><%= sort_link @search, :number, "#{t 'helpers.label.variant.number'}" %></th>
    <th><%= sort_link @search, :price, "#{t 'helpers.label.variant.price'}" %></th>
    <th><%= sort_link @search, :state, "#{t 'helpers.label.variant.state'}" %></th>
    <th colspan="<%= columns %>"><%= "#{t 'helpers.label.variant.parameters'}" %></th>
    <th class="last"></th>
  </thead>
  <tfoot>
    <th><%= remote_button_to_new 'Vytvořit novou variantu', new_admin_product_variant_path(params[:id]), "variant" %></th>
    <th colspan="2"></th>
  </tfoot>
  <tbody>
    <% unless variants.blank? %>
      <%= render :partial => "variant", :collection => variants %>
    <% else %>
      <tr>
        <th colspan="10">Nebyly nalezeny žádné varianty.</th>
      </tr>
    <% end %>
  </tbody>
</table>

<script type="text/javascript">
  jQuery(function() {
    var toggleSpinner = function() {$("#spinner").toggle()};
    
    $(".variant")
      .bind("ajax:beforeSend", toggleSpinner)
      .bind("ajax:complete", toggleSpinner);
  });
</script>